package com.donald.videoHub.entity;




public class R<T> {
    private int code;
    private String message;
    private T data;

     R() {
    }

    public R(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public R(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static R ok(){
         return new R(0,"成功");
    }

    public static <T> R ok(T data){
        return new R(0,"成功",data);
    }

    public static <T> R ok(String data){
        return new R(0,data,data);
    }

    public static R error(){
        return new R(1,"失败");
    }

    public static R error(String message){
        return new R(1,message);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
